# This class defines the different types of fingerprints we have:
# string, regexp, complex (string/regexp + post processor)



import re
from log import log

class FPCheck(object):
	matched=0
	pattern=''


class FPString(FPCheck):
	def __init__(self,pattern):
		self.pattern=pattern

	def check(self,data):
		self.matched=data.count(self.pattern)	
		log("Matched " +str(self.matched)+" x "+ self.pattern)
		return self.matched
		

class FPRegex(FPCheck):
	def __init__(self,pattern):
		self.pattern=pattern
		self.regexp=re.compile(pattern)

	def check(self,data):
		self.matched=len(self.regexp.findall(data))
		log("Matched " +str(self.matched)+" x "+ self.pattern)
		return self.matched
				
